home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8919 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  881 b 

  1. Path: casbah.acns.nwu.edu!muzaffar
  2. From: muzaffar@casbah.acns.nwu.edu (Usman Muzaffar)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: help with bytes -> long
  5. Date: 7 Mar 1996 03:53:27 GMT
  6. Organization: Northwestern University, Evanston IL
  7. Message-ID: <4hlmjn$qju@news.acns.nwu.edu>
  8. References: <4hl3lj$oue@frodo.smartlink.net>
  9. NNTP-Posting-Host: casbah.acns.nwu.edu
  10.  
  11. In article <4hl3lj$oue@frodo.smartlink.net>,
  12. Thomas Hackbarth <thomash@warp10.smartlink.net> wrote:
  13. >I suck at bit manipulation. I need a macro to convert RGB to a long so I
  14. >get this output
  15. >
  16. >RED GREEN BLUE  -> LONG
  17. >FF   00    FF       FF 00 FF 00
  18. >
  19.  
  20. Well, if your compiler can handle long constants, what's wrong with
  21.  
  22. #define RGB2LONG(r,g,b) (r*16777216+g*65536+b*256)
  23.  
  24. It's not quite as slow as it looks: most compiler insert the actual
  25. constant when faced with constx*consty .
  26.  
  27. -usman
  28. muzaffar@casbah.acns.nwu.edu
  29.  
  30.  
  31.  
  32.